
public class Sorter {
	
	public static void sortAscending(int[] Array)
	{
		int temp, max;
		//Scan the complete array
		for(int i = 0; i<Array.length; i++)
		{
			//find out index of largest elements for array length -i
			max = indexOfLargestElement(Array, Array.length-i);
			
			temp = Array[max];
			Array[max] = Array[Array.length-i-1];
			Array[Array.length-i-1] = temp;
		}
	}
	
	public static void sortDescending(int[] Array)
	{
		int temp, min;
		//Scan the complete array
		for(int i = 0; i<Array.length; i++)
		{
			//find out index of largest elements for array length -i
			min = indexOfSmallestElement(Array, Array.length-i);
			
			temp = Array[min];
			Array[min] = Array[Array.length-i-1];
			Array[Array.length-i-1] = temp;
		}
	}
	
	
	private static int indexOfLargestElement(int[] Array, int size)
	{
		int index = 0;
		for(int i = 1; i< size; i ++)
		{
			if(Array[i] > Array[index])
				index = i;
		}
		return index;
	}
	
	private static int indexOfSmallestElement(int[] Array, int size)
	{
		int index = 0;
		for(int i = 1; i< size; i ++)
		{
			if(Array[i] < Array[index])
				index = i;
		}
		return index;
	}
}
